<template>
	<u-popup v-model="game" mode="bottom" border-radius="20" @open="init" @close="cancel">
		<add-gold :platform="platform" @ok="ok" @cannel="cancel"></add-gold>
	</u-popup>
</template>

<script>
	import {mapState} from 'vuex';
	import addGold from "@/components/gold-popup/addGold";	//充值
	export default {
		components: {
			addGold,
		},
		data() {
			return {
				game: false,
				login: {
					appId: '',
					encryptedData: '',
					code: '',
					iv: ''
				},
				platform: '',
			}
		},
		computed: {
			...mapState(['vuex_coin']),
		},
		created() {
			uni.$on('game-gold', this.handleEvents)
		},
		destroyed() {
			// 注销全局配置监听
			uni.$off('game-gold')
		},
		methods: {
			handleEvents(e) {
				this.game = e;
			},
			init() {
				//加载激励广告
				//this.$utils.videoAdInit("adunit-bacaa86c865cf26b");
				var platform = uni.getStorageSync("platform");
				this.platform = platform;
			},
			getAmount() {
				this.$u.get('/pay/userCoin/getAmount').then(res => {
					this.$store.commit('setAmount', res.data);
				});
			},
			ok() {
				this.getAmount();
			},
			cancel() {
				
			},
		}
	}
</script>

<style lang="scss" scoped>
	.tip-info {
		font-size: 30rpx;
		display: flex;
		justify-content: center;
		color: #303133;
		margin-bottom: 15px;
	}
	.page {
		padding: 30px 15px;
	}
	.avatar-box {
		display: flex;
		justify-content: center;
		padding: 15px;
		padding-top: 0;
	}
</style>
